package com.ck.springboot.rabbtimq.conf;

import com.ck.springboot.rabbtimq.constants.Constant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Classname DirectRabbitConfig
 * @Description TODO
 * @Date 2021/3/22 11:52
 * @Created by lpc
 */

@Configuration
public class DirectRabbitConfig {
    @Bean
    public Queue directQueue(){
        return new Queue(Constant.DIRECT_QUEUE,true);
    }

    @Bean
    DirectExchange directExchange() {
        return new DirectExchange(Constant.DIRECT_EXCHANGE,true,false);
    }

    @Bean
    Binding bindingDirect() {
        return BindingBuilder.bind(directQueue()).to(directExchange()).with(Constant.DIRECT_ROUTING);
    }


}
